home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3195 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.1 KB

  1. Path: ep.com!olpe
  2. From: Pete Olpe <olpe@ep.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: MFC 4.0 OnDraw and DC question
  5. Date: Mon, 22 Jan 1996 11:50:29 -0800
  6. Organization: NETCOM Network Operations
  7. Message-ID: <Pine.AUX.3.91.960122113748.8497A-100000@ep.com>
  8. NNTP-Posting-Host: ep.com
  9. Mime-Version: 1.0
  10. Content-Type: TEXT/PLAIN; charset=US-ASCII
  11.  
  12. In my "OnDraw(CDC* pDC)" routine I call another member function that 
  13. performs the actual work of drawing. I pass it the pointer to the DC that 
  14. was passed to the OnDraw() routine.  It is slow, and eventually bombs by 
  15. failing to create a font, or brush, or whatever.  A very simplified 
  16. version of the code follows:
  17.  
  18. myClass::OnDraw(CDC* pDC)
  19. {
  20.    myDrawRoutine(pDC);
  21. }
  22.  
  23. myClass::myDrawRoutine(CDC* pDC)
  24. {
  25.     create fonts, brushes, pens;
  26.     pDC->SelectObject(fonts, brushes, pens, etc);
  27.     pDC->DrawText(...);
  28. }
  29.  
  30.  
  31. When I substitute the code for "myDrawRoutine" back inline in the 
  32. "OnDraw" routine, the drawing speeds up and never seems to bomb by 
  33. failing to create an object or select an object into the DC.
  34.  
  35. Does anyone have any ideas why splitting out the code from an "OnDraw" 
  36. routine would not work?
  37.  
  38.     -Pete-
  39.